# controller.py

import os
from model import SqlQueryBuilder

class SqlQueryController:
    def __init__(self):
        self.builder = SqlQueryBuilder("", {})

    def generate_sql(self, tbl, cons, fields):
        self.builder = SqlQueryBuilder(tbl, cons, fields)
        return self.builder.construct_sql()

    def save_sql(self, sql_query):
        current_directory = os.path.dirname(os.path.abspath(__file__))
        file_path = os.path.join(current_directory, 'sql_query.sql')
        with open(file_path, 'a') as file:
            file.write(sql_query + '\n')
        return file_path